package com.luomo.java.juc.cas;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * CAS:比较并交换
 *
 * @author LiuMei
 * @date 2021-01-14.
 */
public class CASDemo {

    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);
        System.out.println(atomicInteger.compareAndSet(5, 6)+"\t current data:"+atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(5, 7)+"\t current data:"+atomicInteger.get());
    }

}
